﻿<%@ Page Title="Product" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="Detail.aspx.cs" Inherits="Reviews_Detail" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
      .tbDetail {}
      .rating {}
        .auto-style3 {
            width: 289px;
        }
        .auto-style4 {
            width: 221px;
        }
    </style>
    <link href="../Scripts/css/Rating.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        $(function () {
            $('#myGallery').galleryView({
                panel_width: 500,
                panel_height: 300,
                panel_scale: 'fit'
            });
        });
    </script>
    <div class="sidebar">
        <asp:DetailsView CssClass="tbDetail" ID="DetailsView1" runat="server" Height="50px" Width="424px" AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="SqlDataSource1">
            <Fields>
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:BoundField DataField="Expr1" HeaderText="Category" SortExpression="Expr1" />
                <asp:BoundField DataField="Expr2" HeaderText="Brand" SortExpression="Expr2" />
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ProjectASPConnectionString %>"
            SelectCommand="SELECT Products.Id, Products.Type, Products.Name, Products.Brand, Products.Description, ProductType.Name AS Expr1, Brands.Name AS Expr2 FROM Products INNER JOIN ProductType ON Products.Type = ProductType.Id INNER JOIN Brands ON Products.Brand = Brands.Id WHERE (Products.Id = @Id)">
            <SelectParameters>
                <asp:QueryStringParameter Name="Id" QueryStringField="Id" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
    <div class="mainbar">
        <asp:ListView ID="listViewPictures" runat="server" DataSourceID="SqlDataSource2" DataKeyNames="Id" ClientIDMode="Static">
            <EmptyDataTemplate>
                No data was returned.
            </EmptyDataTemplate>
            <ItemSeparatorTemplate>
            </ItemSeparatorTemplate>
            <ItemTemplate>
                <li>
                    <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' AlternateText='<%# "Picture "+Eval("Id") %>' />
                </li>
            </ItemTemplate>
            <LayoutTemplate>
                <ul id="myGallery" runat="server">
                    <li runat="server" id="itemPlaceholder" />
                </ul>
            </LayoutTemplate>
        </asp:ListView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ProjectASPConnectionString %>" SelectCommand="SELECT * FROM [Pictures] WHERE ([Product] = @Product)">
            <SelectParameters>
                <asp:QueryStringParameter Name="Product" QueryStringField="Id" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table class="auto-style1">
                    <tr>
                        <td class="auto-style4">
                            <asp:Label ID="Label1" runat="server" Text="Rate this product"></asp:Label></td>
                        <td>
                            <asp:Rating ID="Rating1" runat="server" MaxRating="10" StarCssClass="filledStar" FilledStarCssClass="filledStar" EmptyStarCssClass="emptyStar" WaitingStarCssClass="filledStar"></asp:Rating>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style4">
                            <asp:Label ID="Label2" runat="server" Text="Motivate yourself"></asp:Label></td>
                        <td>
                            <asp:TextBox ID="DescriptionText" runat="server" AccessKey="D" TextMode="MultiLine" Width="250px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style4">
                            <asp:Button ID="Button1" runat="server" Text="Add" OnClick="Button1_Click" /></td>
                        <td><asp:RequiredFieldValidator ID="RequiredFieldValidator1" Display="Dynamic" runat="server" ControlToValidate="DescriptionText" CssClass="ErrorMessage" ErrorMessage="Motivate yourself"></asp:RequiredFieldValidator></td>
                    </tr>
                </table>

                <asp:GridView CssClass="rating" ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource3" AllowPaging="True" AllowSorting="True" Width="524px">
                    <Columns>
                        <asp:BoundField DataField="User_Id" HeaderText="User" SortExpression="User_Id" />
                        <asp:BoundField DataField="Rating" HeaderText="Rating" SortExpression="Rating" />
                        <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                    </Columns>
                </asp:GridView>


                <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ProjectASPConnectionString %>" SelectCommand="SELECT * FROM [Reviews] WHERE ([Product] = @Product)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="Product" QueryStringField="Id" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>

    </div>
</asp:Content>

